﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.Mvc;

//namespace ShenLan.Common
//{
//    /// <summary>
//    /// 权限属性类,判断是否登录
//    /// </summary>
//    public class IsLogon : FilterAttribute, IAuthorizationFilter
//    {
//        #region IAuthorizationFilter 成员
//        /// <summary>  判断是否已经登录 </summary> 
//        /// <param name="filterContext"></param> 
//        public void OnAuthorization(AuthorizationContext filterContext)
//        {
//            //var user = new TN_DbTaoNiu() .users.SingleOrDefault(u => u.email == "xshai@qq.com" && u.pass == "123");
//            //filterContext.HttpContext.Session["userInfo"] = user;

//            if (filterContext.HttpContext.Session["userInfo"] == null)
//            {
//                string returnUrl = HttpUtility.HtmlEncode(filterContext.HttpContext.Request.Url.AbsoluteUri);
//                string errorMsg = HttpUtility.UrlEncode("高权限操作需要重新登录以验证身份！");
//                string url = string.Format("/User/Logon?returnUrl={0}&error={1}", returnUrl, errorMsg);
//                filterContext.Result = new RedirectResult(url);
//            }
//            else
//            {
//                var user = filterContext.HttpContext.Session["userInfo"] as TaoNiuMemberSystem.Models.Users;
//                if (user.power != -1)
//                {
//                    filterContext.HttpContext.Response.Write("<script>alert('您没有权限进行该操作！确定返回首页。');window.location.href='http://www.itaoniu.com'</script>");
//                }
//            }
//        }
//        #endregion
//    }

//}